package sctu.edu.java.year2016.team02.project.service;


import java.sql.SQLException;

/**
 * Created by Eoly on 2016/6/11.
 */
public class SQLInitialized{
    //数据库初始化函数，若数据不存在或对应表不存在则调用数据库函数创建并初始化
    public void Creat() throws SQLException {
        SQLOperate.createDatabase("NetRunning");
        SQLOperate.createTable("NetAdmin", "Key_words VARCHAR(20)", "userName VARCHAR(20) primary key not null");
        SQLOperate.createTable("Problem",
                "UserNameAndIpAddress VARCHAR(30)",
                "KeyToRE VARCHAR(70) primary key not null",
                "MainMessage VARCHAR(40)",
                "DetailMessage TEXT",
                "SolveResult TEXT",
                "SolvedOrNot int default 0");
        String[] name = {"userName","Key_words"},value = {"admin","123456"};
        if(SQLOperate.insert("NetAdmin", name, value, 0)) System.out.println("初始化成功");
    }
}
